package com.zy.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.DashPathEffect;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

import com.zy.utils.CanvasUtils;
import com.zy.utils.data.Point;

//堆
public class DIYCanvasView002 extends View {


    public DIYCanvasView002(Context context) {
        super(context);
        init(context);
    }


    public DIYCanvasView002(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public DIYCanvasView002(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    public DIYCanvasView002(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        init(context);
    }

    Paint nodePaint;
    Paint textPaint;
    Paint indexPaint;
    Paint assistLinePaint;

    private void init(Context context) {
        nodePaint = new Paint();
        nodePaint.setColor(Color.WHITE);

        textPaint = new Paint();
        //设置文本大小
        textPaint.setTextSize(72);
        //设置文本对齐方式
        textPaint.setTextAlign(Paint.Align.CENTER);
        textPaint.setColor(Color.RED);

        indexPaint = new Paint();
        //设置文本大小
        indexPaint.setTextSize(36);
        //设置文本对齐方式
        indexPaint.setTextAlign(Paint.Align.CENTER);
        indexPaint.setColor(Color.BLUE);


        assistLinePaint = new Paint();
        assistLinePaint.setColor(Color.GRAY);
        DashPathEffect effects = new DashPathEffect(new float[]{20, 10, 20, 10}, 10);
        assistLinePaint.setPathEffect(effects);

    }

    int[] ss = new int[]{6, 5, 8, 7, 4, 3, 2, 1, 6, 5, 8, 7, 4, 3, 2, 1};
    int[] ss1 = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9};


    Paint paint = new Paint();

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);


        paint.setColor(Color.BLUE);
        paint.setAntiAlias(true);
        paint.setARGB(150, 0, 100, 200);
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(10);
        //画一个空心的矩形
        canvas.drawRect(100, 300, 300, 500, paint);
        //画一个实心圆
        //paint.setStyle(Paint.Style.FILL);
        canvas.drawCircle(500, 500, 150, paint);


        CanvasUtils.drawAssistLine(canvas, assistLinePaint, 100);



    }


}
